var app = getApp();

var pageData = {
    data: {
      defaultSize: 'default',
      primarySize: 'default',
      warnSize: 'default',
      disabled: false,
      plain: false,
      loading: false,
      text_val:'',
      UserName:'', //用户名称
      UserPhone:'',//用户电话
      addressValue:'' //地址
    },
    onLoad: function (e) {

    },
    onShow: function () {
      this.setData({
        UserName: app.globalData.UserInfo.nickname,
        UserPhone: app.globalData.UserInfo.phone,
        addressValue: app.globalData.UserInfo.userinfo.address
      });
    },
  warn(e){ //提交 更新的地址
    this.setData({
      loading:true
    });
    var url = app.globalData.HOST + app.APILIST.updatelocation;
    var data = {
      "data": {
        "userid": app.globalData.UserInfo.id,
        "address": this.data.text_val,
      }
    };
    app.WxRequest(url,data, 1,
      (res) => {

        if (res.status_code == 200){
          wx.showToast({
            title: '更新成功',
            image: '/images/dui.png',
            duration: 1000
          });
          this.setData({
            loading: false,
            addressValue: this.data.text_val
          });

        }
      }, (ref) => {
      });

  },
  model_address(e){  //获取 地址的值
    this.data.text_val = e.detail.value;
    // console.log(e.detail.value)
  }

};
Page(pageData);
